package com.song.vo;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;

import java.util.Collection;

/**
 * @Author Klys
 * @Date 2023/6/5 16:57
 * @Description
 * @Version 1.0
 */
@Component    //注意！！！这里要注册给bean
public class SecurityUser implements UserDetails {

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {//用户权限
        return null;
    }

    @Override
    public String getPassword() {//定义密码
        return new BCryptPasswordEncoder().encode("123456");
    }

    @Override
    public String getUsername() {//定义用户名
        return "klys";
    }

    @Override
    public boolean isAccountNonExpired() {//账户没有过期
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {//账户锁定
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {//凭据（密码）过期
        return false;
    }

    @Override
    public boolean isEnabled() {//账户是否可用
        return true;
    }
}
